package com.lxmes.business.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.lxmes.business.domain.CcChukuMain;
import com.lxmes.business.domain.CcStockinfoInfo;
import com.lxmes.common.utils.SecurityUtils;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcWarehouserecord;
import com.lxmes.business.service.ICcWarehouserecordService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 出入库流水Controller
 * 
 * @author 王超
 * @date 2022-07-03
 */
@Api(tags="出入库流水")
@RestController
@RequestMapping("/business/warehouserecord")
public class CcWarehouserecordController extends BaseController
{
    @Autowired
    private ICcWarehouserecordService ccWarehouserecordService;

    /**
     * 查询出入库流水列表
     */
    @ApiOperation("出入库流水列表")
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcWarehouserecord ccWarehouserecord)
    {
        startPage();
        ccWarehouserecord.setDeptId(SecurityUtils.getDeptId());
        List<CcWarehouserecord> list = ccWarehouserecordService.selectCcWarehouserecordList(ccWarehouserecord);
        return getDataTable(list);
    }




    /**
     * 查询出入库流水列表
     */
    @ApiOperation(value="流水移动端列表")
    //查询条件
    @ApiImplicitParams({
            @ApiImplicitParam(name = "queryParams", value = "物料号、物料名称、仓库编号", paramType="query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageSize", value = "分页大小",  required = true,paramType="query",  dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageNum", value = "当前页数",  required = true,paramType="query",   dataType = "int", dataTypeClass = Integer.class)
    })
    @ApiResponses({@ApiResponse(code=200,message = "0k",response = CcChukuMain.class)})
   // @PreAuthorize("@ss.hasPermi('mobile:warehouserecord:list')")
    @GetMapping("/mobileWarehouserecordList")
    public TableDataInfo mobileWarehouserecordList(CcWarehouserecord ccWarehouserecord)
    {
        ccWarehouserecord.setDeptId(SecurityUtils.getDeptId());
        startPage();
        List<CcWarehouserecord> list = ccWarehouserecordService.mobileWarehouserecordList(ccWarehouserecord);
        return getDataTable(list);
    }





    /**
     * 大屏接口
     */
    @ApiOperation("出入库大屏列表")
   // @PreAuthorize("@ss.hasPermi('business:warehouserecord:list')")
    @GetMapping("/listDp")
    public TableDataInfo listDp(CcWarehouserecord ccWarehouserecord)
    {
      //  startPage();
        ccWarehouserecord.setDeptId(SecurityUtils.getDeptId());
        List<CcWarehouserecord> list = ccWarehouserecordService.selectCcWarehouserecordListDp(ccWarehouserecord);
        return getDataTable(list);
    }


    /**
     * 导出出入库流水列表
     */
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:export')")
    @Log(title = "出入库流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcWarehouserecord ccWarehouserecord)
    {
        ccWarehouserecord.setDeptId(SecurityUtils.getDeptId());
        List<CcWarehouserecord> list = ccWarehouserecordService.selectCcWarehouserecordList(ccWarehouserecord);
        ExcelUtil<CcWarehouserecord> util = new ExcelUtil<CcWarehouserecord>(CcWarehouserecord.class);
        util.exportExcel(response, list, "出入库流水数据");
    }

    /**
     * 获取出入库流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccWarehouserecordService.selectCcWarehouserecordById(id));
    }

    /**
     * 新增出入库流水
     */
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:add')")
    @Log(title = "出入库流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcWarehouserecord ccWarehouserecord)
    {
        return toAjax(ccWarehouserecordService.insertCcWarehouserecord(ccWarehouserecord));
    }

    /**
     * 修改出入库流水
     */
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:edit')")
    @Log(title = "出入库流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcWarehouserecord ccWarehouserecord)
    {
        return toAjax(ccWarehouserecordService.updateCcWarehouserecord(ccWarehouserecord));
    }

    /**
     * 删除出入库流水
     */
    @PreAuthorize("@ss.hasPermi('business:warehouserecord:remove')")
    @Log(title = "出入库流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccWarehouserecordService.deleteCcWarehouserecordByIds(ids));
    }
}
